Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firebase (firestore connection) #9

Merged
merged 5 commits into from
Feb 3, 2024
Merged

Firebase (firestore connection) #9

merged 5 commits into from
Feb 3, 2024

Conversation

carletex
Copy link
Contributor

@carletex carletex commented Feb 2, 2024

  • Install firebase-admin lib
  • README update with instructions
  • Test the use of firebase with React server components (listing firestore collections)
  • Make the firestore emulator connection work.

Update: was getting an error (see below) but fixed it by downgrading to 11.x

The emulator works fine, but I'm not able to connect to it from the code (using something similar from what we have a bgv3). I'm getting:

Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.

It shouldn't happen since it's an emulator connection. Tried with the env vars too:

FIREBASE_AUTH_EMULATOR_HOST=127.0.0.1:8080
FIREBASE_EMULATOR_HOST=127.0.0.1:8080
FIRESTORE_EMULATOR_HOST=127.0.0.1:8080
FIRESTORE_AUTH_EMULATOR_HOST=127.0.0.1:8080

We might leave this for a future PR (to not spend too much time on it... since we can use a "live" firestore instance)

Fixes #3

@carletex
Copy link
Contributor Author

carletex commented Feb 2, 2024

Had to downgrade firebase-admin to 11.x, because I couldn't make it work with the firebase local emulator (see OG comment). Will open an issue there.

11.x works for me!

@carletex
Copy link
Contributor Author

carletex commented Feb 2, 2024

lol, the error I was documenting here (with the emulator) might have been fixed just 15 min ago

googleapis/google-auth-library-nodejs#1747

But it might need to be propagated to the @google-cloud/storage package (which is the one that firebase-admin uses)

image

I think we can keep 11.x

Copy link
Member

@technophile-04 technophile-04 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tysm Carlos !! Been playing around with it and everything does seem to work on work on live instances but for some reason for me the Firebase emulator UI is not syncing properly we can tackle it next week 🙌.

In the below-attached video :

Screen.Recording.2024-02-03.at.4.57.58.PM.mov
  1. I ran firebase emulator with some seed data
  2. Started my frontend (I edited listCollections function a bit to add document inside "cohorts" )
  3. Go to localhost:3000 (This ran listCollections and ideally it should have been updated in firebase emulator UI)
  4. for some reason emulator UI is not updating, then I tried deleteing "cohorts" collection to see if its been reflected in SE-2 frontend and its not updated in SE-2 frontend too.

But I might be missing something in while configuring locally.

But in case we meet next week we can debug it and lol I also have few doubts , but merging this for since it works on live instances and I can also tinker more on #8

@technophile-04 technophile-04 merged commit 8d19074 into main Feb 3, 2024
1 check passed
@carletex
Copy link
Contributor Author

carletex commented Feb 5, 2024

Hey @technophile-04

I have experienced that before, and in my case was because of the projectId. On firestoreDB we are doing:

    initializeApp({
      projectId: "buidlguidl-v3",
    });

That needs to match with the local instance project Id. I think you had to specify a project ID when running the emulators the first time, right? You can also do --project <projectId> when initializing the emulators.

Let me know if that helps!

@technophile-04
Copy link
Member

Ohhh yeah actually there was difference in projectId and it seems that when using --import flag it does update the database but when I tried without --import everything was in sync ! Thanks 🙌

@carletex carletex deleted the 3#firebase branch March 6, 2024 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Firebase config
2 participants